package com.colorlight.cloud.gateway.api.message.model;

import com.colorlight.cloud.gateway.api.message.constraint.schedule.ScheduleActions;
import lombok.*;

import java.util.Objects;

import static com.colorlight.cloud.common.constants.CommonConstants.GSON;


/**
 * 指令实体： 包含下发的主题、类型、消息实体 这里的消息实体是实现了转换的消息实体
 *
 * @author Demon
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CommandData<T extends ScheduleActions> {
	private String topic;
	private String type;
	private T content;
	private String uuid;
	private Long seqId;
	
	@Override
	public String toString() {
		String jsonContent = null;
		if (Objects.nonNull(content)) {
			jsonContent = GSON.toJson(this.content);
		}
		return "\ntopic:"
				+ topic
				+ "\n"
				+ "type:"
				+ type
				+ "\n"
				+ "content:"
				+ jsonContent
				+ "\n"
				+ "uuid:"
				+ uuid
				+ "\n"
				+ "seqId:"
				+ seqId;
	}
}
